package com.xx.pmis.web.util;

import java.util.Random;

public class Rand {
	public static String getRand() {
		int i = 1;// i在此程序中只作为判断是否是将随机数添加在首位，防止首位出现0；
		Random r = new Random();
		int tag[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		String str = "";
		int temp = 0;

		while (str.length() < 4) {
			temp = r.nextInt(10);// 取出0(含)~10(不含)之间任意数
			if (i == 1 && temp == 0) {
				continue;
			} else {
				i = 2;
				if (tag[temp] == 0) {
					str = str + temp;
					tag[temp] = 1;
				}
			}
		}
		return str;
	}
}
